import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  // history: createWebHistory(import.meta.env.BASE_URL),
  history:createWebHistory(),
  routes: [
    {
      path:'/',
      redirect:'/login'
    },
    {
      path: '/manager',
      name: 'manager',
      component: () =>import("@/views/Manager.vue"),
      children:[
        {
          path:'/manager/home',
          name:'home',
          component:() => import("@/views/Home.vue")
        },
        {
          path:"/manager/data",
          name:'data',
          component:() => import("@/views/Data.vue")
        },
        {
          path:"/manager/employee",
          name:'employee',
          component:() => import("@/views/Employee.vue")
        },
        {
          path:"/manager/admin",
          name:'admin',
          component:() => import("@/views/Admin.vue")
        },
        {
          path:"/manager/mine",
          name:'mine',
          component:() => import("@/views/Mine.vue")
        },
        {
          path:"/manager/article",
          name:'article',
          component:() => import("@/views/Article.vue")
        },
        {
          path:"/manager/department",
          name:'department',
          component:() => import("@/views/Department.vue")
        }
      ]
    },
    {
      path:"/404",
      name:'NotFound',
      component:() =>import("@/views/404.vue")
    },
    {
      path:"/:pathMatch(.*)",//找不到页面就返回404页面
      redirect:"/404"
    },
    {
      path:"/login",
      name:'login',
      component:() =>import("@/views/Login.vue")
    },
    {
      path:"/register",
      name:'register',
      component:() =>import("@/views/Register.vue")
    }
  ],
})

// router.beforeEach(to,from,next)=>{
//   document.title = 
// }

export default router
